import React from 'react'
import { Divider } from 'antd'
import { LwjButton } from "components";
import LwjTable from 'components/LwjTable/LwjTable'
import moment from 'moment';
import { financialSettlementStatus, financialBusinessType } from "utils/enumConfig"

const List = ({
  onShowDetail,
  onSelectRows,
  ...tableProps
}) => {
  const columns = [
    {
      title: '单据编号',
      dataIndex: 'orderId',
      key: 'orderId',
      width: "15%"
    }, {
      title: '门店名称',
      dataIndex: 'distributorName',
      key: 'distributorName',
      width: "10%",
      render: (text, record, index) => (_.isEmpty(record.distributorName)?record.financialAccountName:text)
    }, {
      title: '下单人',
      dataIndex: 'userName',
      key: 'userName',
      width: "10%",
      render: (text, record, index) => (record.creatorName)
    }, {
      title: '应付金额(元)',
      dataIndex: 'amountPayable',
      key: 'amountPayable',
      width: "8%",
      align: "right",
      render: (text, record, index) => (record.settlementType === "PAYABLE"
        ? record.settlementMoney.toFixed(2)
        : "")
    }, {
      title: '应收金额(元)',
      dataIndex: 'amountReceivable',
      key: 'amountReceivable',
      width: "8%",
      align: "right",
      render: (text, record, index) => (record.settlementType === "RECEIVABLE"
        ? record.settlementMoney.toFixed(2)
        : "")
    }, {
      title: '业务类型',
      dataIndex: 'businessType',
      key: 'businessType',
      width: "8%",
      render: (text, record, index) => (financialBusinessType[record.businessType])
    },
    // {
    //   title: '结算来源',
    //   dataIndex: 'sourceSystem',
    //   key: 'sourceSystem',
    //   width: "6%",
    //   render: (text, record, index) => (record.sourceSystem === "THIRD" ? "第三方" : "分销")
    // },
     {
      title: '结算状态',
      dataIndex: 'settlementStatus',
      key: 'settlementStatus',
      width: "6%",
      render: (text, record, index) => (financialSettlementStatus[record.settlementStatus])
    }, {
      title: '创建日期',
      dataIndex: 'createTime',
      key: 'createTime',
      width: "15%",
      render: (text, record, index) => (moment(record.createTime).format("YYYY-MM-DD HH:mm:ss"))
    }, {
      title: '操作',
      key: 'handle',
      width: "10%",
      render: (text, record) => (
        <span>
          <LwjButton
            tooltip="查看"
            type="primary"
            shape="circle"
            size="small"
            icon="eye"
            onClick={() => onShowDetail(record)} />
        </span>
      )
    }
  ];
  return (
    <div>
      <LwjTable
        {...tableProps}
        columns={columns}
        selectType="multiple"
        onSelectRows={onSelectRows} />
    </div>
  )
};

export default List
